package com.ymttest.database.sqlwapper.sqmarketing;

import java.util.HashMap;
import java.util.List;

import com.ymt.database.SqlManager;
import com.ymttest.database.model.sqmarketing.UserJoinActivity;

public class UserJoinActivityWrapper {

	SqlManager manager;

	public UserJoinActivityWrapper() {
		manager = new SqlManager("sqmarketing");
	}

	@SuppressWarnings("unchecked")
	public UserJoinActivity selectByPrimaryKey(Long id) {

		UserJoinActivity userJoinActivity = null;

		List<UserJoinActivity> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.sqmarketing.UserJoinActivityMapper.selectByPrimaryKey",
						id);
		manager.commit();

		if (result.size() > 0)
			userJoinActivity = result.get(0);

		return userJoinActivity;
	}
	
	@SuppressWarnings("unchecked")
	public UserJoinActivity selectByActivityIdAndUserId(Long activityId, Long userId) {

		UserJoinActivity userJoinActivity = null;
		
		HashMap<String, Long> map = new HashMap<>();
		
		map.put("activity_id", activityId);
		map.put("user_id", userId);

		List<UserJoinActivity> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.sqmarketing.UserJoinActivityMapper.selectByActivityIdAndUserId",
						map);
		manager.commit();

		if (result.size() > 0)
			userJoinActivity = result.get(0);

		return userJoinActivity;
	}
	
	public static void main(String[] args) {
		
		UserJoinActivityWrapper wrapper = new UserJoinActivityWrapper();

		System.out.println(wrapper.selectByActivityIdAndUserId(33L, 20238699L));
	}
}
